﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Collections;
using Wedn.Net.Model;
using System.Collections.Generic;

namespace Wedn.Net.UnitTest
{
    [TestClass]
    public class DALTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            //IUserDAO dao = DbSession.GetCurrentDbSession().UserDAO;
            //User model = dao.Insert(new User()
            //    {
            //        Login = "icestone",
            //        Password = "123",
            //        NickName = "iceStone",
            //        Email = "ice@wedn.net",
            //        RegDate = DateTime.Now,
            //        Role = 0,
            //        Link = "http://blog.wedn.net/",
            //        Status = 0
            //    });
            //int id = model.Id;
            //Assert.AreEqual(id > 0, true);
            //int i = 0;
            //int n = 0;
            //var list = DbSession.Instance.TermDAO.SelectPage<int>(2, 3, out i, t => t.Id == 1, t => t.Id, true);

            //foreach (var item in list)
            //{
            //    Console.Write(item.Name);
            //}
            //var list = new DataModelContainer().Set<Term>()
            //             .Where<Term>(t => true)
            //             .OrderByDescending<Term, int>(t => t.Id)
            //             .Skip<Term>(5 * (2 - 1))
            //             .Take<Term>(5)
            //             .AsQueryable<Term>();
            //var list = new TermDAO().SelectList(t => t.Id == 1);
            //var list = new DataModelContainer().Set<Term>().Where<Term>(t => t.Id == 1).ToList<Term>();
            //var list = SelectList(t => t.Id == 1);
            //foreach (var item in list)
            //{
            //    Console.Write(item.Name);
            //}
            var post = BLLFactory.BLLFactory.Instance.PostManager.SelectSingle(p => p.Id == 102);
            //var rel = post.Relation;
        }
        public virtual IList<Term> SelectList(Func<Term, bool> where)
        {
            return new DataModelContainer().Set<Term>().Where<Term>(where).ToList<Term>();
        }
    }
}
